﻿package plugin.simpleChat.game
{
    import __AS3__.vec.*;
    import cmd.*;
    import com.core.*;
    import com.core.utils.*;
    import com.sh.game.consts.*;
    import com.sh.game.global.*;
    import com.sh.game.net.*;
    import com.sh.game.util.*;
    import flash.display.*;
    import flash.events.*;
    import flash.external.*;
    import flash.filters.*;
    import flash.geom.*;
    import flash.system.*;
    import flash.ui.*;
    import flash.utils.*;
    import manager.*;
    import morn.core.components.*;
    import morn.core.handlers.*;
    import plugin.chatflash.component.*;
    import plugin.chatflash.model.*;
    import plugin.newteam.model.*;
    import plugin.simpleChat.*;
    import plugin.union.*;
    import pluginfw.*;
    import uiresource.friend.*;
    import view.mainUI.*;
    import view.uilt.*;

    public class ChatGame extends ChatUI
    {
        private var _instance:SimpleChat;
        private var _targetDic:Dictionary;
        private var _selected:Box;
        private var _curRid:int = 0;
        private var _totalHeight:int = 0;
        private var _msgDic:Dictionary;
        private var _ShowingTip:Boolean = false;
        private var _sendTime:Number = 0;
        private var isChecking:Boolean = false;
        public var mFilter:DropShadowFilter;
        private var faceVec:Vector.<Object>;
        private var _face:FaceGame;
        private var _timeID:uint = 0;

        public function ChatGame(param1:SimpleChat)
        {
            this._targetDic = new Dictionary();
            this._msgDic = new Dictionary();
            this.mFilter = new DropShadowFilter(0, 0, 0, 0.8, 2, 2, 10, 1);
            this.faceVec = new Vector.<Object>;
            this._instance = param1;
            return;
        }// end function

        override protected function initializeView() : void
        {
            ModelProxy.change("data", "simpleChatIsInit", true);
            var _loc_1:* = Control.create(SimpleChatControl, this);
            ModelProxy.addObserver("simpleChat", _loc_1);
            ModelProxy.addObserver("chat", _loc_1);
            ta_chat.maxChars = 50;
            var _loc_2:* = ModelProxy.getValue("data", "simpleChatMsg");
            if (_loc_2)
            {
                this.doDelayMsg(_loc_2);
            }
            return;
        }// end function

        public function doDelayMsg(param1:Object) : void
        {
            var _loc_2:Object = null;
            for each (_loc_2 in param1)
            {
                
                this.updateMsg(_loc_2);
            }
            return;
        }// end function

        public function initEvent() : void
        {
            list_chater.mouseHandler = new Handler(this.listMouseHandler);
            btn_close.clickHandler = new Handler(this.doMouse, [0]);
            btn_see.clickHandler = new Handler(this.doMouse, [1]);
            btn_copy.clickHandler = new Handler(this.doMouse, [2]);
            btn_team1.clickHandler = new Handler(this.doMouse, [3]);
            btn_team2.clickHandler = new Handler(this.doMouse, [4]);
            btn_union1.clickHandler = new Handler(this.doMouse, [5]);
            btn_union2.clickHandler = new Handler(this.doMouse, [6]);
            btn_send.clickHandler = new Handler(this.doMouse, [7]);
            ta_chat.addEventListener(KeyboardEvent.KEY_DOWN, this.sendMsg);
            btn_pos.clickHandler = new Handler(this.doMouse, [8]);
            btn_trace.clickHandler = new Handler(this.doMouse, [9]);
            ta_chat.addEventListener(FocusEvent.FOCUS_IN, this.doCheck);
            ta_chat.addEventListener(FocusEvent.FOCUS_OUT, this.doCheck);
            this.addEventListener(MouseEvent.MOUSE_DOWN, this.fouseNone);
            ta_chat.addEventListener(MouseEvent.MOUSE_DOWN, this.doStop2);
            panel_chat.addEventListener(MouseEvent.MOUSE_DOWN, this.doStop2);
            cb_light.clickHandler = new Handler(this.doCb);
            btn_expression.clickHandler = new Handler(this.doshowFace);
            btn_small.clickHandler = new Handler(this.doSmall);
            return;
        }// end function

        private function doshowFace() : void
        {
            if (this._face)
            {
                this._face.visible = true;
            }
            else
            {
                this._face = new FaceGame(ta_chat);
                this._face.x = btn_expression.x + btn_expression.width;
                this._face.y = btn_expression.y;
                this.addChild(this._face);
            }
            return;
        }// end function

        private function doCb() : void
        {
            ModelProxy.change("data", "isPrivateLight", cb_light.selected);
            return;
        }// end function

        private function doSmall() : void
        {
            ModelProxy.change("mainui", "addSimpleChator", null);
            this._instance.close();
            return;
        }// end function

        protected function doStop2(event:MouseEvent) : void
        {
            event.stopPropagation();
            if (this._face)
            {
                this._face.visible = false;
            }
            return;
        }// end function

        protected function fouseNone(event:MouseEvent) : void
        {
            GlobalLayer.instance.root.focus = null;
            if (this._face)
            {
                this._face.visible = false;
            }
            return;
        }// end function

        protected function doCheck(event:FocusEvent) : void
        {
            switch(event.type)
            {
                case FocusEvent.FOCUS_IN:
                {
                    if (ta_chat.text == "请输入聊天内容")
                    {
                        ta_chat.text = "";
                    }
                    break;
                }
                case FocusEvent.FOCUS_OUT:
                {
                    if (ta_chat.text == "")
                    {
                        ta_chat.text = "请输入聊天内容";
                    }
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        public function removeEvent() : void
        {
            list_chater.mouseHandler = null;
            btn_close.clickHandler = null;
            btn_see.clickHandler = null;
            btn_copy.clickHandler = null;
            btn_team1.clickHandler = null;
            btn_team2.clickHandler = null;
            btn_union1.clickHandler = null;
            btn_union2.clickHandler = null;
            btn_send.clickHandler = null;
            ta_chat.removeEventListener(KeyboardEvent.KEY_DOWN, this.sendMsg);
            btn_pos.clickHandler = null;
            btn_trace.clickHandler = null;
            ta_chat.removeEventListener(FocusEvent.FOCUS_IN, this.doCheck);
            ta_chat.removeEventListener(FocusEvent.FOCUS_OUT, this.doCheck);
            return;
        }// end function

        private function sendPos() : void
        {
            var _loc_3:Object = null;
            var _loc_4:Object = null;
            var _loc_5:Object = null;
            var _loc_6:Object = null;
            var _loc_7:Array = null;
            var _loc_8:String = null;
            var _loc_1:* = new Date().getTime();
            var _loc_2:* = _loc_1 - this._sendTime;
            if (_loc_2 > 3000)
            {
                _loc_3 = UserData.getUserData();
                _loc_4 = ConfigDictionary.data.maplist;
                _loc_5 = _loc_4[_loc_3.mapid];
                _loc_6 = this._selected.dataSource;
                _loc_7 = [_loc_3.rid, _loc_3.name, _loc_3.vip, _loc_6.rid, _loc_6.name, 0, 0, "", _loc_3.sex, _loc_3.career, _loc_3.rein, _loc_3.level, "", "", 319 + "," + _loc_3.x + "," + _loc_3.y + "," + _loc_3.stageid];
                _loc_8 = _loc_7.join("#!");
                Server.instance.send(110, ChatCMD.ChannelPrivate, _loc_8, 0, ConnectType.SYSTEM);
                this._sendTime = _loc_1;
            }
            else
            {
                ModelProxy.change("movetips", "error", "还需" + int((3000 - _loc_2) / 1000 + 1) + "才能再次发送信息");
            }
            return;
        }// end function

        protected function sendMsg(event:KeyboardEvent) : void
        {
            event.stopPropagation();
            if (event.keyCode == Keyboard.ENTER && event.ctrlKey == true)
            {
                this.doSend();
            }
            return;
        }// end function

        private function doMouse(param1:int) : void
        {
            var _loc_3:Object = null;
            var _loc_2:* = this._selected.dataSource;
            switch(param1)
            {
                case 0:
                {
                    this._instance.close();
                    break;
                }
                case 1:
                {
                    Server.instance.send(114, 7, this._curRid, 0, ConnectType.SYSTEM);
                    break;
                }
                case 2:
                {
                    System.setClipboard(_loc_2.name);
                    break;
                }
                case 3:
                {
                    PluginManager.instance.sendToServer("team", CMDteam.TEAM_INVITE, this._curRid);
                    break;
                }
                case 4:
                {
                    PluginManager.instance.sendToServer("team", CMDteam.TEAM_APPLY, this._curRid);
                    break;
                }
                case 5:
                {
                    UnionSender._19unionInvite(this._curRid);
                    break;
                }
                case 6:
                {
                    UnionSender._47applyForAdd(this._curRid);
                    break;
                }
                case 7:
                {
                    this.doSend();
                    break;
                }
                case 8:
                {
                    this.sendPos();
                    break;
                }
                case 9:
                {
                    _loc_3 = new Object();
                    _loc_3.type = 2;
                    _loc_3.data = _loc_2;
                    PluginManager.instance.openPlugin("tracing", UIGlobel.pointsDic["social"], _loc_3);
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        private function doSend() : void
        {
            var _loc_4:Object = null;
            var _loc_5:Object = null;
            var _loc_6:Array = null;
            var _loc_7:String = null;
            var _loc_8:StringTrie = null;
            var _loc_1:* = ta_chat.text;
            _loc_1 = _loc_1.split("\r").join("");
            if (_loc_1 == "" || _loc_1 == "请输入聊天内容")
            {
                GlobalLayer.instance.root.focus = null;
                ta_chat.text = "请输入聊天内容";
                return;
            }
            var _loc_2:* = new Date().getTime();
            var _loc_3:* = _loc_2 - this._sendTime;
            if (_loc_3 > 3000)
            {
                _loc_4 = UserData.getUserData();
                if (_loc_4.level < 40)
                {
                    ModelProxy.change("movetips", "error", "需要40级才能进行聊天！");
                    return;
                }
                _loc_5 = this._selected.dataSource;
                _loc_1 = _loc_1.replace(/#!""#!/g, "#*!");
                _loc_6 = [_loc_4.rid, _loc_4.name, _loc_4.vip, _loc_5.rid, _loc_5.name, 0, 0, _loc_1, _loc_4.sex, _loc_4.career, _loc_4.rein, _loc_4.level, _loc_4.title, "", ""];
                _loc_7 = _loc_6.join("#!");
                _loc_8 = ModelProxy.getValue("data", "configs1.banednames");
                if (_loc_8)
                {
                    _loc_7 = _loc_8.replaceAll(_loc_7);
                }
                Server.instance.send(110, ChatCMD.ChannelPrivate, _loc_7, 0, ConnectType.SYSTEM);
                ta_chat.text = "";
                this._sendTime = _loc_2;
            }
            else
            {
                ModelProxy.change("movetips", "error", "还需" + int((3000 - _loc_3) / 1000 + 1) + "才能再次发送信息");
            }
            return;
        }// end function

        public function updateMsg(param1:Object) : void
        {
            var _loc_2:Array = null;
            var _loc_3:ChatVO = null;
            var _loc_4:Object = null;
            var _loc_5:int = 0;
            var _loc_6:String = null;
            var _loc_7:String = null;
            var _loc_8:Boolean = false;
            var _loc_9:Vector.<Array> = null;
            var _loc_10:Date = null;
            var _loc_11:String = null;
            var _loc_12:Object = null;
            var _loc_13:Array = null;
            var _loc_14:int = 0;
            var _loc_15:int = 0;
            var _loc_16:Dictionary = null;
            var _loc_17:Object = null;
            var _loc_18:Array = null;
            var _loc_19:Object = null;
            var _loc_20:Array = null;
            var _loc_21:String = null;
            var _loc_22:Object = null;
            var _loc_23:Array = null;
            var _loc_24:int = 0;
            var _loc_25:int = 0;
            var _loc_26:int = 0;
            var _loc_27:Object = null;
            var _loc_28:String = null;
            if (param1.cmd == ChatCMD.ChannelPrivate)
            {
                _loc_2 = param1.msg.split("#!");
                _loc_3 = new ChatVO();
                _loc_3.Type = param1.cmd;
                _loc_3.RoleID = _loc_2[0];
                _loc_3.RoleName = _loc_2[1];
                _loc_3.RoleVip = _loc_2[2];
                _loc_3.ToRoleID = _loc_2[3];
                _loc_3.ToRoleName = _loc_2[4];
                _loc_3.TeamID = _loc_2[5];
                _loc_3.UnionID = _loc_2[6];
                _loc_3.TalkContent = String(_loc_2[7]);
                _loc_3.sex = _loc_2[8];
                _loc_3.career = _loc_2[9];
                _loc_3.rein = _loc_2[10];
                _loc_3.level = _loc_2[11];
                _loc_3.title = _loc_2[12];
                _loc_3.itemList = _loc_2[13];
                _loc_3.msgToAnnounce = _loc_2[14];
                if (_loc_2[15])
                {
                    _loc_3.isGm = _loc_2[15];
                }
                _loc_4 = UserData.getUserData();
                _loc_5 = 0;
                _loc_6 = "#56b938";
                _loc_7 = "";
                _loc_8 = false;
                if (_loc_3.RoleID > 0)
                {
                    _loc_13 = ModelProxy.getValue("data", "heilist");
                    if (_loc_13 && _loc_13.length > 0)
                    {
                        _loc_14 = 0;
                        _loc_15 = _loc_13.length;
                        _loc_14 = 0;
                        while (_loc_14 < _loc_15)
                        {
                            
                            if (_loc_3.RoleID == _loc_13[_loc_14])
                            {
                                return;
                            }
                            _loc_14++;
                        }
                    }
                }
                if (_loc_3.ToRoleID == _loc_4.rid)
                {
                    _loc_5 = _loc_3.RoleID;
                    _loc_7 = _loc_3.RoleName;
                    _loc_6 = "#4fa7db";
                    _loc_16 = ModelProxy.getValue("data", "msgFilterDic");
                }
                else if (_loc_3.RoleID == _loc_4.rid)
                {
                    _loc_5 = _loc_3.ToRoleID;
                    _loc_7 = _loc_3.RoleName;
                    _loc_8 = true;
                }
                else
                {
                    return;
                }
                if (_loc_7.length > 13)
                {
                    return;
                }
                _loc_9 = this._msgDic[_loc_5];
                _loc_10 = new Date();
                if (!_loc_9)
                {
                    if (_loc_8)
                    {
                        return;
                    }
                    _loc_9 = new Vector.<Array>;
                    this._msgDic[_loc_5] = _loc_9;
                    _loc_17 = {rid:_loc_3.RoleID, name:_loc_3.RoleName, sex:_loc_3.sex, career:_loc_3.career, rein:_loc_3.rein, level:_loc_3.level};
                    this.data = _loc_17;
                }
                if (_loc_3.msgToAnnounce)
                {
                    _loc_18 = _loc_3.msgToAnnounce.split(",");
                    _loc_19 = ConfigDictionary.data.announce[_loc_18[0]];
                    if (_loc_19 == null)
                    {
                        return;
                    }
                    _loc_21 = "";
                    if (_loc_18[0] == 319)
                    {
                        _loc_22 = ConfigDictionary.data.maplist[_loc_18[3]];
                        if (_loc_22 == null)
                        {
                            return;
                        }
                        _loc_20 = [_loc_22.name, _loc_18[1], _loc_18[2], _loc_18[3]];
                        _loc_21 = StringUtil.substitute(_loc_19.text.replace(/\|""\|/gi, ","), _loc_20);
                    }
                    else if (_loc_18[0] == 320)
                    {
                        _loc_22 = ConfigDictionary.data.maplist[_loc_18[3]];
                        if (_loc_22 == null)
                        {
                            return;
                        }
                        _loc_20 = [_loc_3.RoleName, _loc_22.name, _loc_18[1], _loc_18[2], _loc_18[3]];
                        _loc_21 = StringUtil.substitute(_loc_19.text.replace(/\|""\|/gi, ","), _loc_20);
                    }
                    _loc_21 = "<font color=\'" + _loc_6 + "\'>" + _loc_21 + "</font>";
                    _loc_11 = _loc_21;
                    _loc_3.TalkContent = _loc_21;
                }
                _loc_9.push([true, this.getTitle(_loc_3) + "<font color=\'" + _loc_6 + "\'>" + _loc_7 + "\t" + _loc_10.hours + ":" + (_loc_10.minutes >= 10 ? (_loc_10.minutes) : ("0" + _loc_10.minutes)) + ":" + (_loc_10.seconds >= 10 ? (_loc_10.seconds) : ("0" + _loc_10.seconds)) + "</font>", _loc_3.career + "_" + _loc_3.sex]);
                _loc_11 = "<font color=\'" + (_loc_3.isGm == "gm" ? ("#ff0000") : ("#ffedee")) + "\'>" + _loc_3.TalkContent + "</font>";
                _loc_12 = ConfigDictionary.data.item;
                if (_loc_3.itemList)
                {
                    _loc_23 = _loc_3.itemList.split(",");
                    _loc_23.pop();
                    while (_loc_23.length > 0)
                    {
                        
                        _loc_24 = _loc_23.shift();
                        _loc_25 = _loc_23.shift();
                        _loc_26 = _loc_23.shift();
                        _loc_27 = _loc_12[_loc_25];
                        if (_loc_27 != null)
                        {
                            if (_loc_24 == 1)
                            {
                                _loc_28 = "<font color=\'" + MColor.getqualitycolor(_loc_27.quality) + "\'><u>[<a href=\'event:item," + _loc_24 + "," + _loc_26 + "\'>" + _loc_27.name + "</a>]</u></font>";
                            }
                            else
                            {
                                _loc_28 = "<font color=\'" + MColor.getqualitycolor(_loc_27.quality) + "\'><u>[<a href=\'event:item," + _loc_24 + "," + _loc_25 + "\'>" + _loc_27.name + "</a>]</u></font>";
                            }
                            _loc_11 = _loc_11.replace("[" + _loc_27.name + "]", _loc_28);
                        }
                    }
                }
                _loc_9.push([false, _loc_3.TalkContent, _loc_11]);
                if (_loc_9.length > 80)
                {
                    _loc_9.shift();
                }
                if (this._curRid == _loc_3.RoleID || this._curRid == _loc_3.ToRoleID)
                {
                    this.showMsg(_loc_9);
                }
                else if (this._curRid == 0)
                {
                    this._curRid = _loc_5;
                    this.showMsg(_loc_9);
                }
            }
            return;
        }// end function

        public function showMsg(param1:Vector.<Array>) : void
        {
            var _loc_2:RichTextField = null;
            var _loc_4:Array = null;
            var _loc_5:Object = null;
            var _loc_6:Array = null;
            var _loc_7:Image = null;
            while (panel_chat.numChildren > 0)
            {
                
                _loc_2 = panel_chat.getChildAt(0) as RichTextField;
                _loc_2.textfield.removeEventListener(TextEvent.LINK, this.doLink);
                _loc_2.textfield.filters = null;
                panel_chat.removeChild(_loc_2);
                _loc_2.dispose();
                _loc_2 = null;
            }
            while (this.faceVec.length > 0)
            {
                
                _loc_5 = this.faceVec.shift();
                if (_loc_5.parent)
                {
                    _loc_5.parent.removeChild(_loc_5);
                }
                _loc_5 = null;
            }
            var _loc_3:int = 0;
            for each (_loc_4 in param1)
            {
                
                _loc_2 = new RichTextField();
                _loc_2.textfield.mouseWheelEnabled = false;
                _loc_2.setSize(390, 100);
                _loc_2.type = RichTextField.DYNAMIC;
                _loc_2.html = true;
                _loc_2.textfield.selectable = false;
                _loc_2.textfield.filters = [this.mFilter];
                _loc_6 = [];
                if (_loc_4[0])
                {
                    if (_loc_4[2] != "0_0")
                    {
                        _loc_7 = new Image("png.chatHead." + _loc_4[2]);
                        this.faceVec.push(_loc_7);
                        _loc_6.push({index:0, src:_loc_7});
                    }
                    _loc_2.append(_loc_4[1], _loc_6);
                }
                else
                {
                    this.checkSprites(_loc_4[1], _loc_6);
                    _loc_2.append(this.getMsg(_loc_4[2]), _loc_6, false, null, false);
                }
                _loc_2.setSize(390, _loc_2.height);
                panel_chat.addChild(_loc_2);
                _loc_2.y = _loc_3;
                _loc_3 = _loc_3 + _loc_2.height;
                _loc_2.textfield.addEventListener(TextEvent.LINK, this.doLink);
            }
            panel_chat.scrollTo(0, _loc_3);
            return;
        }// end function

        private function listMouseHandler(event:MouseEvent, param2:int) : void
        {
            var _loc_3:* = list_chater.getCell(param2);
            switch(event.type)
            {
                case MouseEvent.CLICK:
                {
                    this.setSelect(_loc_3);
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        public function set data(param1:Object) : void
        {
            var _loc_3:Object = null;
            this._targetDic[param1.rid] = param1;
            var _loc_2:Array = [];
            this._curRid = param1.rid;
            for each (_loc_3 in this._targetDic)
            {
                
                if (_loc_3)
                {
                    _loc_2.push(_loc_3);
                }
            }
            list_chater.array = _loc_2;
            list_chater.renderHandler = new Handler(this.chaterHandler);
            return;
        }// end function

        public function set datas(param1:Object) : void
        {
            var _loc_2:Object = null;
            var _loc_3:Array = null;
            var _loc_4:Object = null;
            for (_loc_2 in param1)
            {
                
                this._targetDic[_loc_2] = param1[_loc_2];
                this._curRid = int(_loc_2);
            }
            _loc_3 = [];
            for each (_loc_4 in this._targetDic)
            {
                
                if (_loc_4)
                {
                    _loc_3.push(_loc_4);
                }
            }
            list_chater.array = _loc_3;
            list_chater.renderHandler = new Handler(this.chaterHandler);
            return;
        }// end function

        public function chaterHandler(param1:Component, param2:int) : void
        {
            var _loc_3:Object = null;
            var _loc_4:Image = null;
            var _loc_5:Label = null;
            var _loc_6:Label = null;
            if (param2 < list_chater.length)
            {
                _loc_3 = list_chater.array[param2];
                _loc_4 = param1.getChildByName("img_head") as Image;
                _loc_4.url = "png.chatHead." + _loc_3.career + "_" + _loc_3.sex;
                _loc_5 = param1.getChildByName("txt") as Label;
                _loc_5.text = _loc_3.name;
                if (this._curRid == _loc_3.rid)
                {
                    list_chater.selectedIndex = param2;
                    this.setSelect(param1 as Box);
                }
                _loc_6 = param1.getChildByName("txt_close") as Label;
                _loc_6.dataSource = {msg:_loc_3};
                _loc_6.removeEventListener(MouseEvent.CLICK, this.doClose);
                _loc_6.addEventListener(MouseEvent.CLICK, this.doClose);
            }
            return;
        }// end function

        protected function doClose(event:MouseEvent) : void
        {
            var _loc_5:Object = null;
            event.stopPropagation();
            var _loc_2:* = event.currentTarget.dataSource.msg;
            delete this._targetDic[_loc_2.rid];
            delete this._msgDic[_loc_2.rid];
            ModelProxy.change("mainui", "closeChator", _loc_2.rid);
            var _loc_3:Array = [];
            var _loc_4:Boolean = false;
            for each (_loc_5 in this._targetDic)
            {
                
                if (_loc_5)
                {
                    if (_loc_5.rid == this._curRid)
                    {
                        _loc_4 = true;
                    }
                    _loc_3.push(_loc_5);
                }
            }
            if (_loc_3.length == 0)
            {
                this._instance.close();
            }
            else if (!_loc_4)
            {
                this._curRid = _loc_3[0].rid;
            }
            list_chater.array = _loc_3;
            list_chater.renderHandler = new Handler(this.chaterHandler);
            return;
        }// end function

        public function setSelect(param1:Box) : void
        {
            this._selected = param1;
            var _loc_2:* = param1.dataSource;
            this._curRid = _loc_2.rid;
            this.setImg(_loc_2.career + "_" + _loc_2.sex, img_head);
            txt_name.text = _loc_2.name;
            txt_level.text = _loc_2.level + "等级";
            txt_career.text = UIGlobel.getCareer(_loc_2.career);
            var _loc_3:* = this._msgDic[_loc_2.rid];
            if (!_loc_3)
            {
                _loc_3 = new Vector.<Array>;
                this._msgDic[_loc_2.rid] = _loc_3;
            }
            this.showMsg(_loc_3);
            return;
        }// end function

        private function setImg(param1:String, param2:Image) : void
        {
            var _loc_3:* = "assets/images/head/" + param1 + ".png";
            _loc_3 = Config.getUrl(_loc_3, ResourceType.NORMAL);
            App.mloader3.loadBMD(_loc_3, 1, new Handler(this.onComp, [_loc_3, param2]));
            return;
        }// end function

        private function onComp(param1:String, param2:Image, param3:BitmapData) : void
        {
            param2.url = param1;
            return;
        }// end function

        protected function checkCloseTipHandler(event:MouseEvent) : void
        {
            if (this._ShowingTip)
            {
                this._ShowingTip = false;
                GlobalLayer.instance.root.removeEventListener(MouseEvent.CLICK, this.checkCloseTipHandler);
                ModelProxy.change("tips", "state", "close");
            }
            return;
        }// end function

        private function getTitle(param1:ChatVO) : String
        {
            var _loc_3:Object = null;
            var _loc_4:Object = null;
            var _loc_2:String = "";
            if (param1.isGm == "gm")
            {
                return "<font color=\'#dec026\'><b>【GM】</b></font>";
            }
            if (param1.title > 1000)
            {
                _loc_2 = "<font color=\'{0}\'>{1}</font>";
                _loc_3 = ConfigDictionary.data.title;
                _loc_4 = _loc_3[param1.title];
                switch(int(_loc_4.type))
                {
                    case 0:
                    {
                        _loc_2 = StringUtil.substitute(_loc_2, "#cf6cec", "【" + _loc_4.name + "】");
                        break;
                    }
                    case 1:
                    {
                        _loc_2 = StringUtil.substitute(_loc_2, "#d8a25c", "【" + _loc_4.name + "】");
                        break;
                    }
                    default:
                    {
                        _loc_2 = StringUtil.substitute(_loc_2, "#cf6cec", "【" + _loc_4.name + "】");
                        break;
                        break;
                    }
                }
            }
            return _loc_2;
        }// end function

        private function checkSprites(param1:String, param2:Array) : void
        {
            var _loc_13:String = null;
            var _loc_14:int = 0;
            var _loc_15:Object = null;
            var _loc_16:Clip = null;
            var _loc_17:int = 0;
            var _loc_18:Object = null;
            var _loc_19:Clip = null;
            var _loc_20:Boolean = false;
            var _loc_3:* = ModelProxy.getValue("data", "chatTrie");
            var _loc_4:* = param1.length;
            var _loc_5:String = "";
            var _loc_6:* = _loc_3.getRoot();
            var _loc_7:* = ConfigDictionary.data.face;
            var _loc_8:int = 0;
            var _loc_9:Boolean = false;
            var _loc_10:Boolean = false;
            var _loc_11:Boolean = true;
            var _loc_12:int = 0;
            while (_loc_12 < _loc_4)
            {
                
                _loc_13 = param1.charAt(_loc_12);
                if (this.isChecking)
                {
                    if (_loc_6[_loc_13])
                    {
                        _loc_6 = _loc_6[_loc_13];
                        _loc_5 = _loc_5 + _loc_13;
                        if (_loc_12 == (_loc_4 - 1))
                        {
                            if (_loc_6[""])
                            {
                                this.isChecking = false;
                                _loc_9 = false;
                                _loc_10 = false;
                                _loc_11 = false;
                                _loc_6 = _loc_3.getRoot();
                                _loc_8++;
                                _loc_14 = 0;
                                for each (_loc_15 in _loc_7)
                                {
                                    
                                    if (_loc_15.protocol == _loc_5)
                                    {
                                        _loc_14 = _loc_15.times;
                                        break;
                                    }
                                }
                                _loc_16 = new Clip("png.common." + _loc_5.substr(1), _loc_14, 1);
                                this.faceVec.push(_loc_16);
                                _loc_16.autoPlay = true;
                                _loc_16.interval = 900 / _loc_14 + 100;
                                param2.push({index:_loc_8, src:_loc_16});
                                _loc_5 = "";
                            }
                        }
                    }
                    else if (_loc_6[""])
                    {
                        _loc_6 = _loc_3.getRoot();
                        _loc_17 = 0;
                        for each (_loc_18 in _loc_7)
                        {
                            
                            if (_loc_18.protocol == _loc_5)
                            {
                                _loc_17 = _loc_18.times;
                                break;
                            }
                        }
                        _loc_19 = new Clip("png.common." + _loc_5.substr(1), _loc_17, 1);
                        this.faceVec.push(_loc_19);
                        _loc_20 = _loc_5.length - _loc_12 != 0;
                        _loc_19.autoPlay = true;
                        _loc_19.interval = 900 / _loc_17 + 60;
                        _loc_5 = "";
                        if (_loc_6[_loc_13])
                        {
                            if (!_loc_9)
                            {
                                if (!_loc_10)
                                {
                                    if (_loc_20)
                                    {
                                        if (!_loc_11)
                                        {
                                            _loc_8++;
                                        }
                                    }
                                }
                            }
                            _loc_11 = false;
                            this.isChecking = true;
                            _loc_9 = true;
                            _loc_10 = false;
                            _loc_6 = _loc_6[_loc_13];
                            _loc_5 = _loc_5 + _loc_13;
                            param2.push({index:_loc_8, src:_loc_19});
                        }
                        else
                        {
                            param2.push({index:_loc_8, src:_loc_19});
                            this.isChecking = false;
                            _loc_9 = false;
                            _loc_8++;
                            _loc_10 = true;
                            _loc_11 = false;
                        }
                    }
                    else
                    {
                        _loc_6 = _loc_3.getRoot();
                        if (_loc_6[_loc_13])
                        {
                            this.isChecking = true;
                            _loc_6 = _loc_6[_loc_13];
                            _loc_8 = _loc_8 + _loc_5.length;
                            _loc_5 = "";
                            _loc_5 = _loc_5 + _loc_13;
                        }
                        else
                        {
                            this.isChecking = false;
                            _loc_9 = false;
                            _loc_5 = _loc_5 + _loc_13;
                            _loc_8 = _loc_8 + _loc_5.length;
                            _loc_5 = "";
                        }
                    }
                }
                else if (_loc_6[_loc_13])
                {
                    this.isChecking = true;
                    _loc_6 = _loc_6[_loc_13];
                    _loc_5 = _loc_5 + _loc_13;
                }
                else
                {
                    _loc_8++;
                }
                _loc_12++;
            }
            return;
        }// end function

        private function getMsg(param1:String) : String
        {
            var _loc_8:String = null;
            var _loc_2:* = ModelProxy.getValue("data", "chatTrie");
            var _loc_3:* = param1.length;
            var _loc_4:String = "";
            var _loc_5:String = "";
            var _loc_6:* = _loc_2.getRoot();
            var _loc_7:int = 0;
            while (_loc_7 < _loc_3)
            {
                
                _loc_8 = param1.charAt(_loc_7);
                if (this.isChecking)
                {
                    if (_loc_6[_loc_8])
                    {
                        _loc_6 = _loc_6[_loc_8];
                        _loc_5 = _loc_5 + _loc_8;
                    }
                    else if (_loc_6[""])
                    {
                        _loc_6 = _loc_2.getRoot();
                        _loc_5 = "";
                        if (_loc_6[_loc_8])
                        {
                            this.isChecking = true;
                            _loc_6 = _loc_6[_loc_8];
                            _loc_5 = _loc_5 + _loc_8;
                        }
                        else
                        {
                            this.isChecking = false;
                            _loc_4 = _loc_4 + _loc_8;
                        }
                    }
                    else
                    {
                        _loc_6 = _loc_2.getRoot();
                        if (_loc_6[_loc_8])
                        {
                            this.isChecking = true;
                            _loc_6 = _loc_6[_loc_8];
                            _loc_4 = _loc_4 + _loc_5;
                            _loc_5 = "";
                            _loc_5 = _loc_5 + _loc_8;
                        }
                        else
                        {
                            this.isChecking = false;
                            _loc_5 = _loc_5 + _loc_8;
                            _loc_4 = _loc_4 + _loc_5;
                            _loc_5 = "";
                        }
                    }
                }
                else if (_loc_6[_loc_8])
                {
                    this.isChecking = true;
                    _loc_6 = _loc_6[_loc_8];
                    _loc_5 = _loc_5 + _loc_8;
                }
                else
                {
                    _loc_4 = _loc_4 + _loc_8;
                }
                _loc_7++;
            }
            return _loc_4;
        }// end function

        protected function doLink(event:TextEvent) : void
        {
            var links:Array;
            var p:Point;
            var fun:Function;
            var lv:int;
            var rein:int;
            var data:Object;
            var itemInfo:Object;
            var arr:Array;
            var e:* = event;
            links = e.text.split(",");
            if (links.length > 0)
            {
                p = new Point(GlobalLayer.instance.root.mouseX, GlobalLayer.instance.root.mouseY);
                switch(links[0])
                {
                    case "jsfunc":
                    {
                        ExternalInterface.call(links[1]);
                        break;
                    }
                    case "item":
                    {
                        if (this._ShowingTip)
                        {
                            this._ShowingTip = false;
                            GlobalLayer.instance.root.removeEventListener(MouseEvent.CLICK, this.checkCloseTipHandler);
                            ModelProxy.change("tips", "state", "close");
                        }
                        if (links[1] == 2)
                        {
                            p.y = p.y - 200;
                            itemInfo = ConfigDictionary.data.item[links[2]];
                            if (itemInfo.itemtype == 1)
                            {
                                ModelProxy.change("tips", "arm", {data:itemInfo, p:p});
                            }
                            else
                            {
                                ModelProxy.change("tips", "tool", {data:itemInfo, p:p});
                            }
                        }
                        else
                        {
                            Server.instance.send(110, 9, links[2], 0, ConnectType.SYSTEM);
                        }
                        this._ShowingTip = true;
                        fun = function () : void
            {
                if (_timeID > 0)
                {
                    clearTimeout(_timeID);
                    _timeID = 0;
                }
                GlobalLayer.instance.root.addEventListener(MouseEvent.CLICK, checkCloseTipHandler);
                return;
            }// end function
            ;
                        this._timeID = setTimeout(fun, 100);
                        break;
                    }
                    case "pos":
                    {
                        if (links[3] < 10000)
                        {
                            ModelProxy.change("zone", "autoMove", {x:links[1], y:links[2], tostageid:links[3], onhorse:true});
                        }
                        else
                        {
                            ModelProxy.change("movetips", "error", "目标为不可寻路到达的目的地，不能前往！");
                        }
                        break;
                    }
                    case "transfer":
                    {
                        break;
                    }
                    case "stallage":
                    {
                        ModelProxy.change("plugin", "sendSysMsg", {name:"stallage", param:links[1], cmd:8});
                        break;
                    }
                    case "recharge":
                    {
                        if (Config.gameParams.oper == "qq")
                        {
                            ModelProxy.change("plugin", "open", {target:"qqchongzhi"});
                        }
                        else
                        {
                            ExternalInterface.call("topay");
                        }
                        break;
                    }
                    case "plugin":
                    {
                        lv = UserData.getUserData("level");
                        rein = ModelProxy.getValue("data", "user.rein");
                        if (links[1] == "qianghua")
                        {
                            if (lv < 50)
                            {
                                ItemUilt.ErrortipsForLevel(50);
                                return;
                            }
                        }
                        data = links[2];
                        if (links[1] == "kaifuhd")
                        {
                            arr = String(data).split("#");
                            data = new Object();
                            data.yeqian = arr[0];
                            if (arr.length > 1)
                            {
                                data.id = arr[1];
                            }
                        }
                        ModelProxy.change("plugin", "change", {target:links[1], point:p, data:data});
                        break;
                    }
                    default:
                    {
                        break;
                    }
                }
            }
            return;
        }// end function

    }
}
